package com.tarena.lbs.basic.web.thread;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class CustomThreadLocal<T> {
    private Map<Thread,T> register = new HashMap<>();

    public void save(T value){
        Thread thread = Thread.currentThread();
        register.put(thread,value);
    }
    public T get(){
        Thread thread = Thread.currentThread();
        return register.get(thread);
    }
    //清空
    public void clear(){
        Thread thread = Thread.currentThread();
        register.remove(thread);
    }
}
